-include .config

MAKEFLAGS += --no-print-directory

PREFIX ?= /usr
SBINDIR ?= $(PREFIX)/sbin
#MANDIR ?= $(PREFIX)/share/man
#PKG_CONFIG ?= pkg-config

MKDIR ?= mkdir -p
INSTALL ?= install
CC = gcc

BUILD_PROB = "\"`whoami`@`hostname` `date +"%Y-%m-%d_%T"`\""

CFLAGS ?= -O2 -g
CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration
CFLAGS += -DM11_BUILD_PROPERTY=$(BUILD_PROB)

OBJS = main.o eloop.o cap.o sig.o util.o

ALL = m11

ifeq ($(V),1)
Q=
NQ=true
else
Q=@
NQ=echo
endif

all: $(ALL)

%.o: %.c eloop.h cap.h sig.h util.h types.h version.h
	@$(NQ) ' CC  ' $@
	$(Q)$(CC) $(CFLAGS) -c -o $@ $<

m11: $(OBJS)
	@$(NQ) ' LD  ' m11
	$(Q)$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o m11

install: m11
	@$(NQ) ' INST m11'
	$(Q)$(MKDIR) $(DESTDIR)$(SBINDIR)
	$(Q)$(INSTALL) -m 755 m11 $(DESTDIR)$(SBINDIR)

clean:
	$(Q)rm -f m11 *.o *~ *-stamp
